package com.itcast.cn.myhashset;


import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * @PackageName: com.itcast.cn.myhashset
 * @ClassName: Map01
 * @Author: wusong
 * @Date: 2020/7/7 0007 9:30
 * @Description:
 */
public class Map01 {
    public static void main(String[] args) {
        Map<String, String> map = new HashMap<>();
        map.put("一号丈夫", "一号妻子");
        map.put("二号丈夫", "二号妻子");
        map.put("三号丈夫", "三号妻子");
        map.put("四号丈夫", "四号妻子");
        map.put("五号丈夫", "五号妻子");

        Set<String> keys = map.keySet();
        //迭代器
     /*   Iterator<String> it = keys.iterator();
        while (it.hasNext()){
             String s = it.next();
             String s1 = map.get(s);
            System.out.println(s + " " + s1);
            }
            */
        //增强For
        for (String s : keys) {
            final String s1 = map.get(s);
            System.out.println(s + " " + s1);
        }
    }
}


